.class public Lcom/melesta/engine/DatabaseHelper;
.super Landroid/database/sqlite/SQLiteOpenHelper;
.source "DatabaseHelper.java"


# annotations
.annotation build Landroid/annotation/SuppressLint;
    value = {
        "DefaultLocale"
    }
.end annotation

.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/melesta/engine/DatabaseHelper$IObjectFilter;,
        Lcom/melesta/engine/DatabaseHelper$IDbFileProcessor;,
        Lcom/melesta/engine/DatabaseHelper$IdAndObjectPair;
    }
.end annotation


# static fields
.field private static final ALL_COLUMNS:[Ljava/lang/String; = null

.field private static final CONTENT:Ljava/lang/String; = "content"

.field private static final CONTENT_COLUMN:[Ljava/lang/String; = null

.field private static final DATABASE_NAME:Ljava/lang/String; = "fs"

.field private static final DATABASE_VERSION:I = 0x3

.field private static final PATH:Ljava/lang/String; = "path"

.field private static final PATH_COLUMN:[Ljava/lang/String; = null

.field private static final ROWID:Ljava/lang/String; = "ROWID"

.field private static final ROWID_CONTENT_COLUMNS:[Ljava/lang/String; = null

.field private static final TABLE_NAME:Ljava/lang/String; = "fs"

.field private static final TRANSACTIONS_TABLE_NAME:Ljava/lang/String; = "tmp"

.field private static mInstance:Lcom/melesta/engine/DatabaseHelper;


# instance fields
.field private final mContext:Landroid/content/Context;


# direct methods
.method static constructor <clinit>()V
    .locals 5

    .prologue
    const/4 v4, 0x2

    const/4 v3, 0x1

    const/4 v2, 0x0

    .line 55
    new-array v0, v3, [Ljava/lang/String;

    const-string v1, "path"

    aput-object v1, v0, v2

    sput-object v0, Lcom/melesta/engine/DatabaseHelper;->PATH_COLUMN:[Ljava/lang/String;

    .line 57
    new-array v0, v3, [Ljava/lang/String;

    const-string v1, "content"

    aput-object v1, v0, v2

    sput-object v0, Lcom/melesta/engine/DatabaseHelper;->CONTENT_COLUMN:[Ljava/lang/String;

    .line 59
    new-array v0, v4, [Ljava/lang/String;

    const-string v1, "ROWID"

    aput-object v1, v0, v2

    const-string v1, "content"

    aput-object v1, v0, v3

    sput-object v0, Lcom/melesta/engine/DatabaseHelper;->ROWID_CONTENT_COLUMNS:[Ljava/lang/String;

    .line 60
    new-array v0, v4, [Ljava/lang/String;

    const-string v1, "path"

    aput-object v1, v0, v2

    const-string v1, "content"

    aput-object v1, v0, v3

    sput-object v0, Lcom/melesta/engine/DatabaseHelper;->ALL_COLUMNS:[Ljava/lang/String;

    return-void
.end method

.method private constructor <init>(Landroid/content/Context;)V
    .locals 6
    .parameter "context"

    .prologue
    .line 69
    const-string v3, "fs"

    const/4 v4, 0x0

    const/4 v5, 0x3

    invoke-direct {p0, p1, v3, v4, v5}, Landroid/database/sqlite/SQLiteOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V

    .line 70
    iput-object p1, p0, Lcom/melesta/engine/DatabaseHelper;->mContext:Landroid/content/Context;

    .line 73
    :try_start_0
    invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;

    move-result-object v1

    .line 74
    .local v1, def:Ljava/util/Locale;
    sget-object v3, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;

    invoke-static {v3}, Ljava/util/Locale;->setDefault(Ljava/util/Locale;)V

    .line 76
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 77
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    invoke-static {v1}, Ljava/util/Locale;->setDefault(Ljava/util/Locale;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 81
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v1           #def:Ljava/util/Locale;
    :goto_0
    return-void

    .line 78
    :catch_0
    move-exception v2

    .line 79
    .local v2, e:Ljava/lang/Exception;
    invoke-static {v2}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method public static declared-synchronized getHelper(Landroid/content/Context;)Lcom/melesta/engine/DatabaseHelper;
    .locals 2
    .parameter "context"

    .prologue
    .line 29
    const-class v1, Lcom/melesta/engine/DatabaseHelper;

    monitor-enter v1

    :try_start_0
    sget-object v0, Lcom/melesta/engine/DatabaseHelper;->mInstance:Lcom/melesta/engine/DatabaseHelper;

    if-nez v0, :cond_0

    .line 30
    new-instance v0, Lcom/melesta/engine/DatabaseHelper;

    invoke-direct {v0, p0}, Lcom/melesta/engine/DatabaseHelper;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/melesta/engine/DatabaseHelper;->mInstance:Lcom/melesta/engine/DatabaseHelper;

    .line 32
    :cond_0
    sget-object v0, Lcom/melesta/engine/DatabaseHelper;->mInstance:Lcom/melesta/engine/DatabaseHelper;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit v1

    return-object v0

    .line 29
    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method private declared-synchronized internalGetFilesList()Ljava/util/List;
    .locals 12
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    .line 180
    monitor-enter p0

    :try_start_0
    new-instance v10, Ljava/util/ArrayList;

    invoke-direct {v10}, Ljava/util/ArrayList;-><init>()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 181
    .local v10, files:Ljava/util/List;,"Ljava/util/List<Ljava/lang/String;>;"
    const/4 v0, 0x0

    .line 182
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v8, 0x0

    .line 184
    .local v8, c:Landroid/database/Cursor;
    :try_start_1
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 186
    const-string v1, "fs"

    sget-object v2, Lcom/melesta/engine/DatabaseHelper;->PATH_COLUMN:[Ljava/lang/String;

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 188
    if-eqz v8, :cond_2

    .line 189
    :goto_0
    invoke-interface {v8}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_2

    .line 190
    const/4 v1, 0x0

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v11

    .line 191
    .local v11, fn:Ljava/lang/String;
    invoke-interface {v10, v11}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 194
    .end local v11           #fn:Ljava/lang/String;
    :catch_0
    move-exception v9

    .line 195
    .local v9, e:Ljava/lang/Exception;
    :try_start_2
    invoke-static {v9}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 197
    if-eqz v8, :cond_0

    .line 198
    :try_start_3
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 200
    :cond_0
    if-eqz v0, :cond_1

    .line 204
    .end local v9           #e:Ljava/lang/Exception;
    :cond_1
    :goto_1
    monitor-exit p0

    return-object v10

    .line 197
    :cond_2
    if-eqz v8, :cond_3

    .line 198
    :try_start_4
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 200
    :cond_3
    if-eqz v0, :cond_1

    goto :goto_1

    .line 197
    :catchall_0
    move-exception v1

    if-eqz v8, :cond_4

    .line 198
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 200
    :cond_4
    if-eqz v0, :cond_5

    :cond_5
    throw v1
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 180
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v8           #c:Landroid/database/Cursor;
    .end local v10           #files:Ljava/util/List;,"Ljava/util/List<Ljava/lang/String;>;"
    :catchall_1
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method private declared-synchronized moveToDb(Landroid/database/sqlite/SQLiteDatabase;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    .locals 22
    .parameter "db"
    .parameter "list"
    .parameter "path"
    .parameter "start"

    .prologue
    .line 113
    monitor-enter p0

    if-nez p2, :cond_1

    .line 154
    :cond_0
    :goto_0
    monitor-exit p0

    return-void

    .line 118
    :cond_1
    move-object/from16 v5, p2

    .local v5, arr$:[Ljava/lang/String;
    :try_start_0
    array-length v14, v5

    .local v14, len$:I
    const/4 v12, 0x0

    .local v12, i$:I
    :goto_1
    if-ge v12, v14, :cond_0

    aget-object v11, v5, v12

    .line 119
    .local v11, fn:Ljava/lang/String;
    new-instance v19, Ljava/lang/StringBuilder;

    invoke-direct/range {v19 .. v19}, Ljava/lang/StringBuilder;-><init>()V

    move-object/from16 v0, v19

    move-object/from16 v1, p3

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    .line 120
    .local v13, internalPath:Ljava/lang/String;
    new-instance v9, Ljava/io/File;

    new-instance v19, Ljava/lang/StringBuilder;

    invoke-direct/range {v19 .. v19}, Ljava/lang/StringBuilder;-><init>()V

    move-object/from16 v0, v19

    move-object/from16 v1, p4

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-direct {v9, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 121
    .local v9, f:Ljava/io/File;
    invoke-virtual {v9}, Ljava/io/File;->isFile()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    move-result v19

    if-eqz v19, :cond_2

    .line 123
    :try_start_1
    new-instance v10, Ljava/io/FileInputStream;

    invoke-direct {v10, v9}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    .line 124
    .local v10, fin:Ljava/io/FileInputStream;
    invoke-virtual {v9}, Ljava/io/File;->length()J

    move-result-wide v19

    move-wide/from16 v0, v19

    long-to-int v0, v0

    move/from16 v19, v0

    move/from16 v0, v19

    new-array v6, v0, [B

    .line 126
    .local v6, buffer:[B
    invoke-virtual {v10, v6}, Ljava/io/FileInputStream;->read([B)I

    move-result v15

    .line 127
    .local v15, r:I
    invoke-virtual {v10}, Ljava/io/FileInputStream;->close()V

    .line 131
    new-instance v18, Ljava/lang/String;

    const-string v19, "UTF-8"

    move-object/from16 v0, v18

    move-object/from16 v1, v19

    invoke-direct {v0, v6, v1}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    .line 133
    .local v18, str:Ljava/lang/String;
    new-instance v7, Landroid/content/ContentValues;

    invoke-direct {v7}, Landroid/content/ContentValues;-><init>()V

    .line 134
    .local v7, cv:Landroid/content/ContentValues;
    const-string v19, "path"

    invoke-virtual {v13}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v20

    move-object/from16 v0, v19

    move-object/from16 v1, v20

    invoke-virtual {v7, v0, v1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 135
    const-string v19, "content"

    move-object/from16 v0, v19

    invoke-virtual {v7, v0, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V

    .line 137
    const-string v19, "fs"

    const-string v20, "path"

    move-object/from16 v0, p1

    move-object/from16 v1, v19

    move-object/from16 v2, v20

    invoke-virtual {v0, v1, v2, v7}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v16

    .line 141
    .local v16, rid:J
    invoke-virtual {v9}, Ljava/io/File;->delete()Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 118
    .end local v6           #buffer:[B
    .end local v7           #cv:Landroid/content/ContentValues;
    .end local v10           #fin:Ljava/io/FileInputStream;
    .end local v15           #r:I
    .end local v16           #rid:J
    .end local v18           #str:Ljava/lang/String;
    :goto_2
    add-int/lit8 v12, v12, 0x1

    goto/16 :goto_1

    .line 143
    :catch_0
    move-exception v8

    .line 144
    .local v8, e:Ljava/lang/Exception;
    :try_start_2
    sget-object v19, Ljava/lang/System;->out:Ljava/io/PrintStream;

    move-object/from16 v0, v19

    invoke-virtual {v0, v8}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_1

    goto :goto_2

    .line 151
    .end local v8           #e:Ljava/lang/Exception;
    .end local v9           #f:Ljava/io/File;
    .end local v11           #fn:Ljava/lang/String;
    .end local v12           #i$:I
    .end local v13           #internalPath:Ljava/lang/String;
    .end local v14           #len$:I
    :catch_1
    move-exception v8

    .line 152
    .restart local v8       #e:Ljava/lang/Exception;
    :try_start_3
    invoke-static {v8}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto/16 :goto_0

    .line 113
    .end local v8           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v19

    monitor-exit p0

    throw v19

    .line 147
    .restart local v9       #f:Ljava/io/File;
    .restart local v11       #fn:Ljava/lang/String;
    .restart local v12       #i$:I
    .restart local v13       #internalPath:Ljava/lang/String;
    .restart local v14       #len$:I
    :cond_2
    :try_start_4
    invoke-virtual {v9}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v19

    new-instance v20, Ljava/lang/StringBuilder;

    invoke-direct/range {v20 .. v20}, Ljava/lang/StringBuilder;-><init>()V

    move-object/from16 v0, v20

    invoke-virtual {v0, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    const-string v21, "/"

    invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    invoke-virtual/range {v20 .. v20}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v20

    move-object/from16 v0, p0

    move-object/from16 v1, p1

    move-object/from16 v2, v19

    move-object/from16 v3, v20

    move-object/from16 v4, p4

    invoke-direct {v0, v1, v2, v3, v4}, Lcom/melesta/engine/DatabaseHelper;->moveToDb(Landroid/database/sqlite/SQLiteDatabase;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 148
    invoke-virtual {v9}, Ljava/io/File;->delete()Z
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_2
.end method


# virtual methods
.method public deleteAllFiles()V
    .locals 5

    .prologue
    .line 480
    const/4 v0, 0x0

    .line 482
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 484
    const-string v2, "fs"

    const-string v3, "ROWID!=-1"

    const/4 v4, 0x0

    new-array v4, v4, [Ljava/lang/String;

    invoke-virtual {v0, v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 488
    if-eqz v0, :cond_0

    .line 492
    :cond_0
    :goto_0
    return-void

    .line 485
    :catch_0
    move-exception v1

    .line 486
    .local v1, e:Ljava/lang/Exception;
    :try_start_1
    invoke-static {v1}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 488
    if-eqz v0, :cond_0

    goto :goto_0

    .end local v1           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v2

    if-eqz v0, :cond_1

    :cond_1
    throw v2
.end method

.method public declared-synchronized deleteTransaction(J)Z
    .locals 11
    .parameter "internalId"

    .prologue
    const/4 v3, 0x1

    const/4 v4, 0x0

    .line 454
    monitor-enter p0

    const/4 v0, 0x0

    .line 456
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 457
    const-string v5, "tmp"

    const-string v6, "ROWID=?"

    const/4 v7, 0x1

    new-array v7, v7, [Ljava/lang/String;

    const/4 v8, 0x0

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v9, p1, p2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ""

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    aput-object v9, v7, v8

    invoke-virtual {v0, v5, v6, v7}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v2

    .line 458
    .local v2, rId:I
    if-eqz v2, :cond_1

    .line 462
    :goto_0
    if-eqz v0, :cond_0

    .line 466
    .end local v2           #rId:I
    :cond_0
    :goto_1
    monitor-exit p0

    return v3

    .restart local v2       #rId:I
    :cond_1
    move v3, v4

    .line 458
    goto :goto_0

    .line 459
    .end local v2           #rId:I
    :catch_0
    move-exception v1

    .line 460
    .local v1, e:Ljava/lang/Exception;
    :try_start_1
    invoke-static {v1}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 462
    if-eqz v0, :cond_2

    :cond_2
    move v3, v4

    .line 466
    goto :goto_1

    .line 462
    .end local v1           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v3

    if-eqz v0, :cond_3

    :cond_3
    :try_start_2
    throw v3
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    .line 454
    :catchall_1
    move-exception v3

    monitor-exit p0

    throw v3
.end method

.method public declared-synchronized fileDelete(Ljava/lang/String;)V
    .locals 7
    .parameter "fn"

    .prologue
    .line 280
    monitor-enter p0

    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 281
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v2, "fs"

    const-string v3, "path=?"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    invoke-virtual {v0, v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 286
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    :goto_0
    monitor-exit p0

    return-void

    .line 283
    :catch_0
    move-exception v1

    .line 284
    .local v1, e:Ljava/lang/Exception;
    :try_start_1
    invoke-static {v1}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 280
    .end local v1           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method public declared-synchronized forEachFile(Lcom/melesta/engine/DatabaseHelper$IDbFileProcessor;)V
    .locals 12
    .parameter "iDbFileProcessor"

    .prologue
    .line 289
    monitor-enter p0

    const/4 v8, 0x0

    .line 291
    .local v8, c:Landroid/database/Cursor;
    if-nez p1, :cond_1

    .line 312
    if-eqz v8, :cond_0

    .line 313
    :try_start_0
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 316
    :cond_0
    :goto_0
    monitor-exit p0

    return-void

    .line 294
    :cond_1
    :try_start_1
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 296
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "fs"

    sget-object v2, Lcom/melesta/engine/DatabaseHelper;->ALL_COLUMNS:[Ljava/lang/String;

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 298
    if-eqz v8, :cond_2

    .line 299
    :goto_1
    invoke-interface {v8}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_2

    .line 300
    const/4 v1, 0x0

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v11

    .line 301
    .local v11, fn:Ljava/lang/String;
    const/4 v1, 0x1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getBlob(I)[B
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v9

    .line 303
    .local v9, content:[B
    :try_start_2
    invoke-interface {p1, v11, v9}, Lcom/melesta/engine/DatabaseHelper$IDbFileProcessor;->process(Ljava/lang/String;[B)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_1

    goto :goto_1

    .line 304
    :catch_0
    move-exception v10

    .line 305
    .local v10, e:Ljava/io/IOException;
    :try_start_3
    invoke-static {v10}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_1

    goto :goto_1

    .line 309
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v9           #content:[B
    .end local v10           #e:Ljava/io/IOException;
    .end local v11           #fn:Ljava/lang/String;
    :catch_1
    move-exception v10

    .line 310
    .local v10, e:Ljava/lang/Exception;
    :try_start_4
    invoke-static {v10}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 312
    if-eqz v8, :cond_0

    .line 313
    :try_start_5
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    goto :goto_0

    .line 289
    .end local v10           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1

    .line 312
    .restart local v0       #db:Landroid/database/sqlite/SQLiteDatabase;
    :cond_2
    if-eqz v8, :cond_0

    .line 313
    :try_start_6
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    goto :goto_0

    .line 312
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    :catchall_1
    move-exception v1

    if-eqz v8, :cond_3

    .line 313
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    :cond_3
    throw v1
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0
.end method

.method public getDbModificationTime()J
    .locals 5

    .prologue
    .line 474
    new-instance v0, Ljava/io/File;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v4, p0, Lcom/melesta/engine/DatabaseHelper;->mContext:Landroid/content/Context;

    invoke-virtual {v4}, Landroid/content/Context;->getApplicationInfo()Landroid/content/pm/ApplicationInfo;

    move-result-object v4

    iget-object v4, v4, Landroid/content/pm/ApplicationInfo;->dataDir:Ljava/lang/String;

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, "/databases/"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, "fs"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v0, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 475
    .local v0, f:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->lastModified()J

    move-result-wide v1

    .line 476
    .local v1, lastMod:J
    return-wide v1
.end method

.method public declared-synchronized getFile(Ljava/lang/String;)[B
    .locals 14
    .parameter "fileName"

    .prologue
    const/4 v13, 0x0

    .line 227
    monitor-enter p0

    const/4 v0, 0x0

    .line 228
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v8, 0x0

    .line 230
    .local v8, c:Landroid/database/Cursor;
    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 231
    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v11

    .line 233
    .local v11, fn:Ljava/lang/String;
    const-string v1, "fs"

    sget-object v2, Lcom/melesta/engine/DatabaseHelper;->CONTENT_COLUMN:[Ljava/lang/String;

    const-string v3, "path=?"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    aput-object v11, v4, v5

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 235
    const/4 v9, 0x0

    .line 237
    .local v9, content:[B
    if-eqz v8, :cond_0

    .line 238
    invoke-interface {v8}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 239
    const/4 v1, 0x0

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getBlob(I)[B

    move-result-object v9

    .line 240
    new-instance v12, Ljava/lang/String;

    const-string v1, "UTF-8"

    invoke-direct {v12, v9, v1}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    .line 241
    .local v12, str:Ljava/lang/String;
    invoke-virtual {v12}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 250
    .end local v12           #str:Ljava/lang/String;
    :cond_0
    if-eqz v8, :cond_1

    .line 251
    :try_start_1
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .end local v9           #content:[B
    .end local v11           #fn:Ljava/lang/String;
    :cond_1
    :goto_0
    monitor-exit p0

    return-object v9

    .line 246
    :catch_0
    move-exception v10

    .line 247
    .local v10, e:Ljava/lang/Exception;
    :try_start_2
    invoke-static {v10}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 250
    if-eqz v8, :cond_2

    .line 251
    :try_start_3
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    :cond_2
    move-object v9, v13

    goto :goto_0

    .line 250
    .end local v10           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v1

    if-eqz v8, :cond_3

    .line 251
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    :cond_3
    throw v1
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 227
    :catchall_1
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public getFilesList(Z)Ljava/util/List;
    .locals 2
    .parameter "tryToMoveFilesToDbFiles"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(Z)",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    .line 169
    invoke-direct {p0}, Lcom/melesta/engine/DatabaseHelper;->internalGetFilesList()Ljava/util/List;

    move-result-object v0

    .line 171
    .local v0, files:Ljava/util/List;,"Ljava/util/List<Ljava/lang/String;>;"
    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v1

    if-nez v1, :cond_0

    if-eqz p1, :cond_0

    .line 172
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->moveFilesToDb()V

    .line 173
    invoke-direct {p0}, Lcom/melesta/engine/DatabaseHelper;->internalGetFilesList()Ljava/util/List;

    move-result-object v0

    .line 176
    :cond_0
    return-object v0
.end method

.method public declared-synchronized getTransaction(J)Lcom/melesta/payment/PaymentTransaction;
    .locals 13
    .parameter "internalId"

    .prologue
    .line 411
    monitor-enter p0

    const/4 v0, 0x0

    .line 412
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v8, 0x0

    .line 414
    .local v8, c:Landroid/database/Cursor;
    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 416
    const-string v1, "tmp"

    sget-object v2, Lcom/melesta/engine/DatabaseHelper;->ROWID_CONTENT_COLUMNS:[Ljava/lang/String;

    const-string v3, "ROWID=?"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    invoke-static {p1, p2}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v8

    .line 418
    if-nez v8, :cond_2

    .line 419
    const/4 v12, 0x0

    .line 438
    if-eqz v8, :cond_0

    .line 439
    :try_start_1
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .line 441
    :cond_0
    if-eqz v0, :cond_1

    .line 446
    :cond_1
    :goto_0
    monitor-exit p0

    return-object v12

    .line 422
    :cond_2
    :try_start_2
    invoke-interface {v8}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_6

    .line 423
    const/4 v1, 0x0

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v11

    .line 424
    .local v11, rid:I
    const/4 v1, 0x1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getBlob(I)[B

    move-result-object v1

    invoke-static {v1}, Lcom/melesta/engine/Cipher;->decrypt([B)[B

    move-result-object v9

    .line 426
    .local v9, content:[B
    invoke-static {v9}, Lcom/melesta/payment/PaymentTransaction;->deserialize([B)Lcom/melesta/payment/PaymentTransaction;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    move-result-object v12

    .line 427
    .local v12, tr:Lcom/melesta/payment/PaymentTransaction;
    if-nez v12, :cond_4

    .line 428
    const/4 v12, 0x0

    .line 438
    .end local v12           #tr:Lcom/melesta/payment/PaymentTransaction;
    if-eqz v8, :cond_3

    .line 439
    :try_start_3
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 441
    :cond_3
    if-eqz v0, :cond_1

    goto :goto_0

    .line 431
    .restart local v12       #tr:Lcom/melesta/payment/PaymentTransaction;
    :cond_4
    int-to-long v1, v11

    :try_start_4
    iput-wide v1, v12, Lcom/melesta/payment/PaymentTransaction;->internalId:J
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    .line 438
    if-eqz v8, :cond_5

    .line 439
    :try_start_5
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 441
    :cond_5
    if-eqz v0, :cond_1

    goto :goto_0

    .line 438
    .end local v9           #content:[B
    .end local v11           #rid:I
    .end local v12           #tr:Lcom/melesta/payment/PaymentTransaction;
    :cond_6
    if-eqz v8, :cond_7

    .line 439
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_1

    .line 441
    :cond_7
    if-eqz v0, :cond_8

    .line 446
    :cond_8
    :goto_1
    const/4 v12, 0x0

    goto :goto_0

    .line 435
    :catch_0
    move-exception v10

    .line 436
    .local v10, e:Ljava/lang/Exception;
    :try_start_6
    invoke-static {v10}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0

    .line 438
    if-eqz v8, :cond_9

    .line 439
    :try_start_7
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 441
    :cond_9
    if-eqz v0, :cond_8

    goto :goto_1

    .line 438
    .end local v10           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v1

    if-eqz v8, :cond_a

    .line 439
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 441
    :cond_a
    if-eqz v0, :cond_b

    :cond_b
    throw v1
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_1

    .line 411
    :catchall_1
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public getTransactions()Ljava/util/List;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lcom/melesta/payment/PaymentTransaction;",
            ">;"
        }
    .end annotation

    .prologue
    .line 470
    const/4 v0, 0x0

    invoke-virtual {p0, v0}, Lcom/melesta/engine/DatabaseHelper;->getTransactions(Lcom/melesta/engine/DatabaseHelper$IObjectFilter;)Ljava/util/List;

    move-result-object v0

    return-object v0
.end method

.method public declared-synchronized getTransactions(Lcom/melesta/engine/DatabaseHelper$IObjectFilter;)Ljava/util/List;
    .locals 14
    .parameter "filter"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/melesta/engine/DatabaseHelper$IObjectFilter;",
            ")",
            "Ljava/util/List",
            "<",
            "Lcom/melesta/payment/PaymentTransaction;",
            ">;"
        }
    .end annotation

    .prologue
    .line 370
    monitor-enter p0

    const/4 v0, 0x0

    .line 371
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v8, 0x0

    .line 372
    .local v8, c:Landroid/database/Cursor;
    :try_start_0
    new-instance v11, Ljava/util/ArrayList;

    invoke-direct {v11}, Ljava/util/ArrayList;-><init>()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 375
    .local v11, result:Ljava/util/List;,"Ljava/util/List<Lcom/melesta/payment/PaymentTransaction;>;"
    :try_start_1
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 377
    const-string v1, "tmp"

    sget-object v2, Lcom/melesta/engine/DatabaseHelper;->ROWID_CONTENT_COLUMNS:[Ljava/lang/String;

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 379
    if-eqz v8, :cond_4

    .line 380
    :cond_0
    :goto_0
    invoke-interface {v8}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_4

    .line 381
    const/4 v1, 0x0

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v12

    .line 382
    .local v12, rid:I
    const/4 v1, 0x1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getBlob(I)[B

    move-result-object v1

    invoke-static {v1}, Lcom/melesta/engine/Cipher;->decrypt([B)[B

    move-result-object v9

    .line 384
    .local v9, content:[B
    invoke-static {v9}, Lcom/melesta/payment/PaymentTransaction;->deserialize([B)Lcom/melesta/payment/PaymentTransaction;

    move-result-object v13

    .line 385
    .local v13, tr:Lcom/melesta/payment/PaymentTransaction;
    if-eqz v13, :cond_0

    .line 389
    int-to-long v1, v12

    iput-wide v1, v13, Lcom/melesta/payment/PaymentTransaction;->internalId:J

    .line 391
    if-eqz p1, :cond_1

    invoke-interface {p1, v13}, Lcom/melesta/engine/DatabaseHelper$IObjectFilter;->filter(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 392
    :cond_1
    invoke-interface {v11, v13}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 396
    .end local v9           #content:[B
    .end local v12           #rid:I
    .end local v13           #tr:Lcom/melesta/payment/PaymentTransaction;
    :catch_0
    move-exception v10

    .line 397
    .local v10, e:Ljava/lang/Exception;
    :try_start_2
    invoke-static {v10}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 399
    if-eqz v8, :cond_2

    .line 400
    :try_start_3
    invoke-interface {v8}, Landroid/database/Cursor;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 402
    :cond_2
    if-eqz v0, :cond_3

    .line 407
    .end local v10           #e:Ljava/lang/Exception;
    :cond_3
    :goto_1
    monitor-exit p0

    return-object v11

    .line 399
    :cond_4
    if-eqz v8, :cond_5

    .line 400
    :try_start_4
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 402
    :cond_5
    if-eqz v0, :cond_3

    goto :goto_1

    .line 399
    :catchall_0
    move-exception v1

    if-eqz v8, :cond_6

    .line 400
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 402
    :cond_6
    if-eqz v0, :cond_7

    :cond_7
    throw v1
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 370
    .end local v11           #result:Ljava/util/List;,"Ljava/util/List<Lcom/melesta/payment/PaymentTransaction;>;"
    :catchall_1
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public declared-synchronized isExists(Ljava/lang/String;)Z
    .locals 9
    .parameter "_id"

    .prologue
    const/4 v3, 0x1

    const/4 v4, 0x0

    .line 208
    monitor-enter p0

    const/4 v1, 0x0

    .line 209
    .local v1, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v0, 0x0

    .line 211
    .local v0, cursor:Landroid/database/Cursor;
    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 212
    const-string v5, "select 1 from fs where path=%s"

    const/4 v6, 0x1

    new-array v6, v6, [Ljava/lang/String;

    const/4 v7, 0x0

    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v8

    aput-object v8, v6, v7

    invoke-virtual {v1, v5, v6}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 213
    invoke-interface {v0}, Landroid/database/Cursor;->getCount()I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v5

    if-lez v5, :cond_1

    .line 220
    .local v3, exists:Z
    :goto_0
    if-eqz v0, :cond_0

    .line 221
    :try_start_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .end local v3           #exists:Z
    :cond_0
    :goto_1
    monitor-exit p0

    return v3

    :cond_1
    move v3, v4

    .line 213
    goto :goto_0

    .line 216
    :catch_0
    move-exception v2

    .line 217
    .local v2, e:Ljava/lang/Exception;
    :try_start_2
    invoke-static {v2}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 220
    if-eqz v0, :cond_2

    .line 221
    :try_start_3
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    :cond_2
    move v3, v4

    goto :goto_1

    .line 220
    .end local v2           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v4

    if-eqz v0, :cond_3

    .line 221
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    :cond_3
    throw v4
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 208
    :catchall_1
    move-exception v4

    monitor-exit p0

    throw v4
.end method

.method public declared-synchronized moveFilesToDb()V
    .locals 2

    .prologue
    .line 107
    monitor-enter p0

    :try_start_0
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 108
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    invoke-virtual {p0, v0}, Lcom/melesta/engine/DatabaseHelper;->moveFilesToDb(Landroid/database/sqlite/SQLiteDatabase;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 110
    monitor-exit p0

    return-void

    .line 107
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method declared-synchronized moveFilesToDb(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 4
    .parameter "db"

    .prologue
    .line 101
    monitor-enter p0

    :try_start_0
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v3

    invoke-virtual {v3}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "/Android/data/"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    iget-object v3, p0, Lcom/melesta/engine/DatabaseHelper;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "/ToyDefense/"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 102
    .local v1, profilesRoot:Ljava/lang/String;
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 103
    .local v0, dir:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v2

    const-string v3, ""

    invoke-direct {p0, p1, v2, v3, v1}, Lcom/melesta/engine/DatabaseHelper;->moveToDb(Landroid/database/sqlite/SQLiteDatabase;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 104
    monitor-exit p0

    return-void

    .line 101
    .end local v0           #dir:Ljava/io/File;
    .end local v1           #profilesRoot:Ljava/lang/String;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method public onCreate(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 4
    .parameter "db"

    .prologue
    .line 86
    :try_start_0
    const-string v0, "CREATE TABLE fs (path TEXT PRIMARY KEY,content BLOB);"

    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    .line 91
    :goto_0
    :try_start_1
    const-string v0, "CREATE TABLE %s (%s BLOB);"

    const/4 v1, 0x2

    new-array v1, v1, [Ljava/lang/Object;

    const/4 v2, 0x0

    const-string v3, "tmp"

    aput-object v3, v1, v2

    const/4 v2, 0x1

    const-string v3, "content"

    aput-object v3, v1, v2

    invoke-static {v0, v1}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 95
    :goto_1
    invoke-virtual {p0, p1}, Lcom/melesta/engine/DatabaseHelper;->moveFilesToDb(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 96
    return-void

    .line 92
    :catch_0
    move-exception v0

    goto :goto_1

    .line 87
    :catch_1
    move-exception v0

    goto :goto_0
.end method

.method public onUpgrade(Landroid/database/sqlite/SQLiteDatabase;II)V
    .locals 4
    .parameter "db"
    .parameter "oldVersion"
    .parameter "newVersion"

    .prologue
    .line 160
    :try_start_0
    const-string v0, "CREATE TABLE %s (%s BLOB);"

    const/4 v1, 0x2

    new-array v1, v1, [Ljava/lang/Object;

    const/4 v2, 0x0

    const-string v3, "tmp"

    aput-object v3, v1, v2

    const/4 v2, 0x1

    const-string v3, "content"

    aput-object v3, v1, v2

    invoke-static {v0, v1}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 165
    :goto_0
    const-string v0, "engine"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Upgrading database from version "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " to "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/melesta/engine/Log;->w(Ljava/lang/String;Ljava/lang/String;)V

    .line 166
    return-void

    .line 161
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method public declared-synchronized saveFile(Ljava/lang/String;[B)V
    .locals 10
    .parameter "fileName"
    .parameter "data"

    .prologue
    .line 258
    monitor-enter p0

    :try_start_0
    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v5

    .line 259
    .local v5, fn:Ljava/lang/String;
    new-instance v2, Landroid/content/ContentValues;

    invoke-direct {v2}, Landroid/content/ContentValues;-><init>()V

    .line 260
    .local v2, cv:Landroid/content/ContentValues;
    const-string v7, "path"

    invoke-virtual {v2, v7, v5}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 261
    const-string v7, "content"

    invoke-virtual {v2, v7, p2}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V

    .line 265
    new-instance v6, Ljava/lang/String;

    const-string v7, "UTF-8"

    invoke-direct {v6, p2, v7}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    .line 267
    .local v6, str:Ljava/lang/String;
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v3

    .line 268
    .local v3, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v7, "fs"

    const-string v8, "path"

    invoke-virtual {v3, v7, v8, v2}, Landroid/database/sqlite/SQLiteDatabase;->replace(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v0

    .line 269
    .local v0, count:J
    const-wide/16 v7, -0x1

    cmp-long v7, v0, v7

    if-nez v7, :cond_0

    .line 270
    const-string v7, "engine"

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "Can\'t update file:"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v7, v8}, Lcom/melesta/engine/Log;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 276
    .end local v0           #count:J
    .end local v2           #cv:Landroid/content/ContentValues;
    .end local v3           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v5           #fn:Ljava/lang/String;
    .end local v6           #str:Ljava/lang/String;
    :cond_0
    :goto_0
    monitor-exit p0

    return-void

    .line 273
    :catch_0
    move-exception v4

    .line 274
    .local v4, e:Ljava/lang/Exception;
    :try_start_1
    invoke-static {v4}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 258
    .end local v4           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v7

    monitor-exit p0

    throw v7
.end method

.method public saveTransaction(JLcom/melesta/payment/PaymentTransaction;)J
    .locals 3
    .parameter "rid"
    .parameter "transaction"

    .prologue
    .line 319
    invoke-virtual {p3}, Lcom/melesta/payment/PaymentTransaction;->serialize()[B

    move-result-object v2

    invoke-virtual {p0, p1, p2, v2}, Lcom/melesta/engine/DatabaseHelper;->saveTransaction(J[B)J

    move-result-wide v0

    .line 320
    .local v0, id:J
    iput-wide v0, p3, Lcom/melesta/payment/PaymentTransaction;->internalId:J

    .line 321
    return-wide v0
.end method

.method public declared-synchronized saveTransaction(J[B)J
    .locals 10
    .parameter "rid"
    .parameter "transaction"

    .prologue
    const-wide/16 v6, -0x1

    .line 326
    monitor-enter p0

    :try_start_0
    invoke-static {p3}, Lcom/melesta/engine/Cipher;->encrypt([B)[B
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    move-result-object v5

    .line 328
    .local v5, yourBytes:[B
    const/4 v3, 0x0

    .line 330
    .local v3, db:Landroid/database/sqlite/SQLiteDatabase;
    :try_start_1
    new-instance v2, Landroid/content/ContentValues;

    invoke-direct {v2}, Landroid/content/ContentValues;-><init>()V

    .line 331
    .local v2, cv:Landroid/content/ContentValues;
    const-string v8, "content"

    invoke-virtual {v2, v8, v5}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V

    .line 333
    invoke-virtual {p0}, Lcom/melesta/engine/DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v3

    .line 335
    const-wide/16 v8, 0x0

    cmp-long v8, p1, v8

    if-gez v8, :cond_2

    .line 336
    const-string v8, "tmp"

    const-string v9, "content"

    invoke-virtual {v3, v8, v9, v2}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v0

    .line 337
    .local v0, count:J
    cmp-long v8, v0, v6

    if-nez v8, :cond_0

    .line 338
    const-string v8, "engine"

    const-string v9, "Can\'t insert transaction"

    invoke-static {v8, v9}, Lcom/melesta/engine/Log;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 352
    :cond_0
    if-eqz v3, :cond_1

    .line 361
    .end local v0           #count:J
    .end local v2           #cv:Landroid/content/ContentValues;
    .end local v3           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v5           #yourBytes:[B
    :cond_1
    :goto_0
    monitor-exit p0

    return-wide v0

    .line 342
    .restart local v2       #cv:Landroid/content/ContentValues;
    .restart local v3       #db:Landroid/database/sqlite/SQLiteDatabase;
    .restart local v5       #yourBytes:[B
    :cond_2
    :try_start_2
    const-string v8, "ROWID"

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v9

    invoke-virtual {v2, v8, v9}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V

    .line 343
    const-string v8, "tmp"

    const-string v9, "content"

    invoke-virtual {v3, v8, v9, v2}, Landroid/database/sqlite/SQLiteDatabase;->replace(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v0

    .line 344
    .restart local v0       #count:J
    cmp-long v8, v0, v6

    if-nez v8, :cond_3

    .line 345
    const-string v8, "engine"

    const-string v9, "Can\'t insert transaction"

    invoke-static {v8, v9}, Lcom/melesta/engine/Log;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    .line 352
    :cond_3
    if-eqz v3, :cond_1

    goto :goto_0

    .line 349
    .end local v0           #count:J
    .end local v2           #cv:Landroid/content/ContentValues;
    :catch_0
    move-exception v4

    .line 350
    .local v4, e:Ljava/lang/Exception;
    :try_start_3
    invoke-static {v4}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 352
    if-eqz v3, :cond_4

    .end local v3           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v5           #yourBytes:[B
    :cond_4
    :goto_1
    move-wide v0, v6

    .line 361
    goto :goto_0

    .line 352
    .end local v4           #e:Ljava/lang/Exception;
    .restart local v3       #db:Landroid/database/sqlite/SQLiteDatabase;
    .restart local v5       #yourBytes:[B
    :catchall_0
    move-exception v8

    if-eqz v3, :cond_5

    :cond_5
    :try_start_4
    throw v8
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_1

    .line 357
    .end local v3           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v5           #yourBytes:[B
    :catch_1
    move-exception v4

    .line 358
    .restart local v4       #e:Ljava/lang/Exception;
    :try_start_5
    invoke-static {v4}, Lcom/melesta/engine/Error;->processException(Ljava/lang/Exception;)V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_1

    goto :goto_1

    .line 326
    .end local v4           #e:Ljava/lang/Exception;
    :catchall_1
    move-exception v6

    monitor-exit p0

    throw v6
.end method

.method public saveTransaction(Lcom/melesta/payment/PaymentTransaction;)J
    .locals 2
    .parameter "tr"

    .prologue
    .line 450
    iget-wide v0, p1, Lcom/melesta/payment/PaymentTransaction;->internalId:J

    invoke-virtual {p0, v0, v1, p1}, Lcom/melesta/engine/DatabaseHelper;->saveTransaction(JLcom/melesta/payment/PaymentTransaction;)J

    move-result-wide v0

    return-wide v0
.end method
